package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.HashMap;

@Getter
@Setter
public class Salary {
    private Long id;

    private BigDecimal money;

    private Integer year;

    private Integer month;

    private Employee employee;

    private SystemDictionaryItem payout;

    public String getJson() {
        //封装数据更加安全
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("year", year);
        map.put("month", month);
        map.put("money", money);
        if (payout != null) {
            map.put("employeeId", employee.getId());
        }
        if (payout != null) {
            map.put("payoutId", payout.getId());
        }

        return JSON.toJSONString(map);
    }


}